#ifndef __SERIAL_H
#define __SERIAL_H

#include "stm32f10x.h"
#include <stdarg.h>
#include <stdio.h>
#include "delay.h"

#define RX485 GPIO_ResetBits(GPIOA, GPIO_Pin_8)
#define TX485 GPIO_SetBits(GPIOA, GPIO_Pin_8)

struct Packet_Type
{
 uint8_t msgtype;
 uint8_t payload[64];
};

extern struct Packet_Type Serial;

void Serial_Init(uint32_t baud_rate);
void Serial_SendByte(uint8_t Byte);
void Serial_SendArray(uint8_t *Array, uint16_t Length);
void Serial_SendString(char *String);
void Serial_SendNumber(uint32_t Number, uint8_t Length);
void Serial_Printf(char *format, ...);

void Serial_SendPacket(void);
uint8_t Serial_GetRxFlag(void);

#endif
